package com.huawei.springboot2023.business.menu.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huawei.springboot2023.business.menu.dto.Menu;
import com.huawei.springboot2023.business.menu.service.IMenuService;
import com.huawei.springboot2023.business.warehouse.dto.Warehouse;
import com.huawei.springboot2023.business.warehouse.service.IWarehouseService;
import com.huawei.springboot2023.core.dto.MyResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ChenHongYun
 * @since 2023-04-10
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Resource(name = "menuServiceImpl")
    private IMenuService menuService;


    /**
     * 获取菜单列表
     * @return
     */
    @GetMapping("/getList")
    @ResponseBody
    public MyResult getList(){

        System.out.println("--------获取菜单列表--------");
        MyResult result = new MyResult();

        List<Menu> list = menuService.list();
        if (list.size() > 0) {
            result.setMsg("获取菜单列表成功");
            result.setCode("0000");
            result.setData(list);
        }else {
            result.setCode("9999");
            result.setMsg("您还没用新增菜单，请先新增菜单");
        }
        return result;

    }

    @GetMapping("/updateMenu")
    @ResponseBody
    public MyResult updateMenu(@RequestBody Menu menu){

        System.out.println("--------获取菜单列表--------");
        MyResult result = new MyResult();

        QueryWrapper qw = new QueryWrapper<>();

        qw.eq("menuId",menu.getMenuId());
         boolean b   = menuService.update(qw);
//        if (list.size() > 0) {
//            result.setMsg("获取菜单列表成功");
//            result.setCode("0000");
//            result.setData(list);
//        }else {
//            result.setCode("9999");
//            result.setMsg("您还没用新增菜单，请先新增菜单");
//        }
        return result;

    }



}
